package com.ct.controller.shipping;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ct.application.shipping.model.po.LiChuanShenQingSavePO;
import com.ct.application.shipping.model.po.LiChuanShenQingSearchPO;
import com.ct.application.shipping.model.po.LiuChengYeWuSavePO;
import com.ct.application.shipping.model.vo.LiChuanShenQingVO;
import com.ct.application.shipping.service.LiChuanShenQingService;
import com.ct.commons.BaseController;
import com.ct.commons.annotation.ApiLog;
import com.ct.commons.annotation.HasAdmin;
import com.ct.commons.annotation.PermissionApi;
import com.ct.commons.aspect.limiter.AccessIpLimiter;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 离船申请配置
 * @author Auto Generator
 * @since 2023-08-16
 */
@RestController
@PermissionApi(title = "离船申请",path="/api/v1/lichuanshenqing",code = "LK1000",sorted = 18)
public class LiChuanShenQingController extends BaseController {

    @Resource
    private LiChuanShenQingService liChuanShenQingService;

    /**
     * 查询离船申请列表
     * @param liChuanShenQingSearchPO
     * @return
     */
    @PostMapping("/lichuanshenqing/list")
    @PermissionApi(title = "查询离船申请列表",path="/api/v1/lichuanshenqing/list",code = "LK1001",sorted = 1)
    public Page<LiChuanShenQingVO> findLiChuanShenQings(@Validated @RequestBody LiChuanShenQingSearchPO liChuanShenQingSearchPO) {
        return liChuanShenQingService.findLiChuanShenQing(liChuanShenQingSearchPO);
    }

    /**
     * 保存和更新
     *
     * @param savePO
     * @return
     */
    @PostMapping("/lichuanshenqing/saveupdate")
    @ApiLog("离船申请保存和更新")
    @HasAdmin
    @AccessIpLimiter
    @PermissionApi(title = "离船申请保存和更新",path="/api/v1/lichuanshenqing/saveupdate",code = "LK1003",sorted = 3)
    public Boolean saveUpdateLiChuanShenQing(@Validated @RequestBody LiChuanShenQingSavePO savePO) {
        return liChuanShenQingService.saveLiChuanShenQing(savePO);
    }

    /**
     * 根据id查询离船申请
     */
    @PostMapping("/lichuanshenqing/get/{id}")
    @PermissionApi(title = "根据id查询离船申请",path="/api/v1/lichuanshenqing/get/{id}",code = "LK1004",sorted = 4)
    public LiChuanShenQingVO getLiChuanShenQingById(@PathVariable("id") Long id) {
        return liChuanShenQingService.getLiChuanShenQing(id);
    }


    /**
     * 审批
     */
    @PostMapping("/lichuanshenqing/shenpi")
    @ApiLog("离船申请审批操作")
    @AccessIpLimiter
    @PermissionApi(title = "离船申请审批操作",path="/api/v1/lichuanshenqing/shenpi",code = "LK1007",sorted = 3)
    public Boolean shenpi(@Validated @RequestBody LiuChengYeWuSavePO savePO) {
        return liChuanShenQingService.shenPi(savePO);
    }



}
